
**************************************************************************************************************
**************************************************************************************************************
*****Replication Code for "The Leadership Dilemma: Examining the Impact of Strong Leaders on Parties**********
*****************European Journal of Political Research*******************************************************
*******************Despina Alexiadou & Eoin O'Malley**********************************************************
**************************************************************************************************************
********************

use "/alexiadou_o'malley_strong_leaders.dta""

*****************************
****************************
****Preparing IVs & DVs*****
********************************
*************************************
gen entrydate=mdy( monthentry, dayentry, yearentry)
gen exitdate=mdy( monthexit, dayexit, yearexit)
gen birthdate=mdy( bymonth, bday, byear)
format entrydate %tdDD/NN/CCYY
format exitdate %tdDD/NN/CCYY
format birthdate %tdDD/NN/CCYY
gen tenure= exitdate- entrydate
gen tenure_year= yearexit-yearentry
replace tenure_year=. if yearexit==.

gen electiondate=date(election_date, "YMD", 2020)
format electiondate %d
gen election_year=year(electiondate)
drop if election_year<1946
bysort party (election_year): gen edate1=electiondate[_n-1]
format edate1 %d

gen exit=.
replace exit=1 if edate1==. & rightcensored==0
replace exit=1 if edate1>exitdate
recode exit .=0 if exitdate!=.
recode exit .=0 if rightcensored==1

/* generate the tenure variable from entry date to election dates or to exit date if it is before elections */
gen tenure2=electiondate-entrydate
replace tenure2=tenure if exit==1 | rightcensored==1
label variable tenure2 `"time from assuming the position till next election or stepdown"'

/* drop tenure2==0 as it is unlikely that leadership changes just before elections; it must be after elections */
drop if tenure2==0
drop if tenure==.

/* drop if entrydate==edate because it is unlikely that leadership changes just before elections; it must be after elections */
drop if entrydate==electiondate

gen entryage=(entrydate-birthdate)/365
gen entryage_years=(yearentry-byear)

****************************************
****Generate Successor to Strong Leader
*****************************************
bysort partyleaderid (year): gen high_control=0
bysort partyleaderid (year): replace high_control=1  if leader_control >6.9
bysort partyleaderid (year): replace high_control=. if leader_control==.

***successor to strong leader**
bysort party_id (year): gen high_control_lag=high_control[_n-1]
bysort party_id (year): gen post_high_control=0
bysort party_id (year): replace post_high_control=1 if newpartyleader==1 & high_control_lag==1
bysort party_id (year): replace post_high_control=1 if newpartyleader==0 & post_high_control[_n-1]==1
bysort party_id (year): replace post_high_control=. if high_control_lag==.

***successors to long-tenured leaders****
***seven years
gen leader_tenure7=1 if tenure_year>7 & tenure_year!=.
recode leader_tenure7 .=0 if tenure_year!=.

bysort party_id (year): gen tenure7_lag=leader_tenure7[_n-1]
bysort party_id (year):gen post_tenure7=0
bysort party_id (year):replace post_tenure7=1 if newpartyleader==1 & tenure7_lag==1
bysort party_id (year):replace post_tenure7=1 if newpartyleader==0 & post_tenure7[_n-1]==1
bysort party_id (year):replace post_tenure7=. if tenure7_lag==.

*************************************
****DVs & Control Variables*****

bysort party_id(year): gen Voteshare1=vote_share[_n-1]
bysort party_id(year): gen Changepervote=vote_share-Voteshare1
bysort party_id(year): gen Changepervotel=Changepervote[_n-1]


label variable leader_control "Strong Leader"
label variable high_control "Strong Leader: Binary"
label variable post_high_control "Successor to Strong Leader"
label variable tenure "Leader Tenure"
label variable post_tenure7 "Successor to Long-Tenured Leader"
label variable Voteshare1 "Lagged Vote Share"
label variable Changepervote "Change in Vote"
label variable Changepervotel "Lagged Change in Vote"

*************************************
***************************************
*******Analysis************************
*****************************************
******************************************
********************************************

********************************************
****Figures 1& 2 ****************************
********************************************

**********************************
****Figure 1 *********************
**********************************

hist leader_control, percent ///
             scheme(s2mono) ///
             graphregion(fcolor(white)) ///
			 xtitle(Leader's Control of Party Organisation) title(Control of Party Organisation by Party Leader) 
graph export "leader_control_fig1_EJPR1.pdf", replace

***********************
********Figure 2*****
************************
twoway scatter leader_control  tenure2 || lfit  leader_control tenure2,  ///
             scheme(s2mono) ///
			 graphregion(fcolor(white)) ///
			 legend(off) ///
			 xtitle(Length of leaders' tenure in days) ///
			 title(Leader's Control of Party Organisation and Tenure)
graph export "leader_tenure_control_fig2_tenure2_EJPR1.pdf", replace	


**************************************
*********Table 2*************************
**************************************
tabstat leader_control high_control post_high_control tenure_year post_tenure7, by(country)

estpost tabstat leader_control high_control post_high_control tenure_year post_tenure7, by(country_name)  stat(mean)
esttab . using table2des.csv, cells("leader_control high_control post_high_control tenure_year post_tenure7") noobs nostar nomtitle nonumber plain

*****Set data for survival analysis********
****survival******************************
******************************************
stset tenure2, id(partyleaderid) failure(newpartyleader)

**************************
***Figure 4***************
***Survival Graph**
stcox  post_high_control leader_control entryage Changepervotel  i.ccode if newpartyleader==1, cluster(party_id)

stcurve, survival at1(post_high_control=0) at2(post_high_control=1) ///
             scheme(s2mono) ///
			 graphregion(fcolor(white)) ///
			 legend (col(1) lab (1 "Successors to Non-Strong leaders") lab(2 "Successors to Strong Leaders")) ///
			 xtitle("Length of leaders' tenure in days") ///
			 subtitle(Survival of Successors to Strong Leaders) xlab(500 1000 1500 2000) ///
			 note("Model 1, Table 3")
graph export "leader_survival_ejprR1_fig4.pdf", replace 


*******************************
*******************************
******Table 3******************
********************************
********************************
stcox  post_high_control leader_control entryage Changepervotel  i.ccode if newpartyleader==1, cluster(party_id)
outreg2 using "LeadersEJPR1_T1", bdec(4) excel eform  
stcox  post_high_control post_tenure7 leader_control entryage Changepervotel  i.ccode if newpartyleader==1, cluster(party_id)
outreg2 using "LeadersEJPR1_T1", bdec(4) excel eform 
stcox  post_high_control post_tenure7 leader_control entryage Changepervotel  selection i.ccode if newpartyleader==1, cluster(party_id) 
outreg2 using "LeadersEJPR1_T1", bdec(4) excel eform
stcox  post_high_control leader_control entryage Changepervotel if newpartyleader==1, cluster(party_id)
outreg2 using "LeadersEJPR1_T1", bdec(4) excel eform  
stcox  post_high_control post_tenure7 leader_control entryage Changepervotel if newpartyleader==1, cluster(party_id)
outreg2 using "LeadersEJPR1_T1", bdec(4) excel eform 
stcox  post_high_control post_tenure7 leader_control entryage Changepervotel  selection if newpartyleader==1, cluster(party_id) 
outreg2 using "LeadersEJPR1_T1", bdec(4) excel eform

*******************************
*******************************
******Table 4******************
********************************
********************************

gen post_high_tenure7=post_high_control*post_tenure7

probit newpartyleader post_high_control leader_control cabinet_party_lag imf_ue cabinet_party_lag_ue entryage selection i.ccode, cluster(party_id) 
outreg2 using "LeadersEJPR1_T1A", bdec(4) excel eform  
probit newpartyleader post_high_control post_tenure7 leader_control cabinet_party_lag imf_ue cabinet_party_lag_ue entryage selection i.ccode, cluster(party_id) 
outreg2 using "LeadersEJPR1_T1A", bdec(4) excel eform  
probit newpartyleader post_high_control post_tenure7 leader_control cabinet_party_lag imf_ue cabinet_party_lag_ue entryage selection, cluster(party_id) 
outreg2 using "LeadersEJPR1_T1A", bdec(4) excel eform  
probit newpartyleader post_high_control post_tenure7 leader_control cabinet_party_lag imf_ue cabinet_party_lag_ue entryage , cluster(party_id) 
outreg2 using "LeadersEJPR1_T1A", bdec(4) excel eform  
medeff (probit post_tenure7 post_high_control Changepervote) (probit newpartyleader post_high_control post_tenure7 post_high_tenure7 leader_control cabinet_party_lag imf_ue cabinet_party_lag_ue entryage), treat(post_high_control) mediate(post_tenure7) interact(post_high_tenure7) vce(robust)
outreg2 using "LeadersEJPR1_T1A", bdec(4) excel eform  


*******************************
*******************************
******Table 5******************
********************************
********************************
reg Changepervote post_high_control newpartyleader leader_control  Voteshare1  cabinet_party_lag imf_ue cabinet_party_lag_ue greatrecession  i.ccode, cluster(party_id)
outreg2 using "LeadersEJPR1_T2", bdec(4) excel 
reg Changepervote post_high_control post_tenure7 newpartyleader leader_control  Voteshare1  cabinet_party_lag imf_ue cabinet_party_lag_ue  greatrecession  i.ccode, cluster(party_id)
outreg2 using "LeadersEJPR1_T2", bdec(4) excel 
medeff (probit post_tenure7 post_high_control Changepervote) (regress Changepervote post_high_control post_tenure7 post_high_tenure7 newpartyleader leader_control  Voteshare1  cabinet_party_lag imf_ue cabinet_party_lag_ue greatrecession greece netherlands portugal spain uk), treat(post_high_control) mediate(post_tenure7) interact(post_high_tenure7) vce(robust)
outreg2 using "LeadersEJPR1_T2", bdec(4) excel 
medeff (probit post_tenure7 post_high_control Changepervote) (regress Changepervote post_high_control post_tenure7 post_high_tenure7 newpartyleader leader_control  Voteshare1  cabinet_party_lag imf_ue cabinet_party_lag_ue greatrecession ), treat(post_high_control) mediate(post_tenure7) interact(post_high_tenure7) vce(robust)
outreg2 using "LeadersEJPR1_T2", bdec(4) excel 
reg Changepervote post_high_control post_tenure7 leader_control  Voteshare1  cabinet_party_lag imf_ue cabinet_party_lag_ue  greatrecession  i.ccode if newpartyleader==1, cluster(party_id)
outreg2 using "LeadersEJPR1_T2", bdec(4) excel 
reg Changepervote post_high_control post_tenure7 leader_control  Voteshare1  cabinet_party_lag imf_ue cabinet_party_lag_ue  greatrecession  if newpartyleader==1, cluster(party_id)
outreg2 using "LeadersEJPR1_T2", bdec(4) excel 


*************************
*****Online Appendix*****
*************************
***Figure 1***************
*****************************

twoway scatter leader_control  bopla_ext, mlabel(country)  || lfit  leader_control bopla_ext , ///
             scheme(s2mono) ///
			 graphregion(fcolor(white)) ///
			 legend(off) ///
			 xtitle("Leadership dominated Parties (Schumacher & Giger)") ///
			 ytitle("Leader's Control of Party Organisation") ///
			 title(Leader's Control of Party vis-a-vis Leadership Dominated Parties, size(medium)) ylab(2 4 6 8 10)
			 graph save Party_Control_Leader_Dom, replace
graph export "Party_Control_Leader_Dom.pdf", replace

